package test3

object GAojie4 {
  def main(args: Array[String]): Unit = {
    var li = List("dog cat snake elephent pig horse", "java hadoop scala list c++");
    println(li.length + "," + li);
    var l3 = li.flatMap(_.split(" "))
    //var l3 = li.flatten(_.split(" "))
    println(l3.length + "," + l3);
    println(l3.getClass());
    ///
    var m=Map("dog"->"小狗","cat"->"猫","snake"->"蛇","pig"->"猪")
    println(m)
    //展开，m的 key，value 作为 list的一项
    val map= m.flatMap(x => {
      //println(x._1+"..."+ x._2)
        List(x._1, x._2)
    })
    println(">>>>>>>>>>>>"+map.size)
    println(map)
  }
}
